import { IPSDELogic } from './ipsdelogic';
import { IPSDELogicLinkSingleCond } from './ipsdelogic-link-single-cond';
import { IPSDELogicParam } from './ipsdelogic-param';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDELogicLinkSingleCondImpl extends PSModelObjectImpl implements IPSDELogicLinkSingleCond {
  get codeName(): string {
    return this.M.codeName;
  }

  get condOP(): string {
    return this.M.condOP;
  }

  get dstFieldName(): string {
    return this.M.dstFieldName;
  }

  protected dstlogicparam: IPSDELogicParam | null = null;

  getDstLogicParam(): IPSDELogicParam | null {
    if (this.dstlogicparam != null) return this.dstlogicparam;
    const value = this.M.getDstLogicParam;
    if (value == null) {
      return null;
    }
    const ipsdelogic = this.getParentPSModelObject('dataentity.logic.IPSDELogic') as IPSDELogic;
    if (ipsdelogic != null) {
      this.dstlogicparam = ipsdelogic.findPSDELogicParam(value);
    }
    return this.dstlogicparam;
  }

  get dstLogicParam(): IPSDELogicParam | null {
    return this.getDstLogicParam();
  }

  getDstLogicParamMust(): IPSDELogicParam {
    const value = this.getDstLogicParam();
    if (value == null) {
      throw new Error('未指定目标逻辑参数对象');
    }
    return value;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get logicType(): 'GROUP' | 'SINGLE' {
    return this.M.logicType;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  get paramType(): 'ENTITYFIELD' | 'CURTIME' {
    return this.M.paramType;
  }

  get paramValue(): string {
    return this.M.paramValue;
  }

  protected srclogicparam: IPSDELogicParam | null = null;

  getSrcLogicParam(): IPSDELogicParam | null {
    if (this.srclogicparam != null) return this.srclogicparam;
    const value = this.M.getSrcLogicParam;
    if (value == null) {
      return null;
    }
    const ipsdelogic = this.getParentPSModelObject('dataentity.logic.IPSDELogic') as IPSDELogic;
    if (ipsdelogic != null) {
      this.srclogicparam = ipsdelogic.findPSDELogicParam(value);
    }
    return this.srclogicparam;
  }

  get srcLogicParam(): IPSDELogicParam | null {
    return this.getSrcLogicParam();
  }

  getSrcLogicParamMust(): IPSDELogicParam {
    const value = this.getSrcLogicParam();
    if (value == null) {
      throw new Error('未指定源逻辑参数对象');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get value(): string {
    return this.M.value;
  }

  get cls(): string {
    return 'PSDELogicLinkSingleCondImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.logic.IPSDELogicLinkSingleCond') return true;
    return super.instanceof(cls);
  }
}
